package com.cloud.controller;

import com.cloud.service.IOrderService;
import com.cloud.service.feginService.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping(value = "/order")
public class OrderController {

    @Value("${server.port}")
    private String serverPort;

    @Value("${spring.application.name}")
    private String serverName;

    @Resource
    private PaymentService paymentService;

    @Resource
    private IOrderService orderService;

    @GetMapping(value = "/getServerPort/{id}")
    public String getServerPort(@PathVariable("id") Integer id){
        return serverName + ", serverPort: " + serverPort + ", id: " + id;
    }

    @GetMapping(value = "/getServerPort/payment/{id}")
    public String getPaymentServerPort(@PathVariable("id") Integer id){
        return paymentService.getServerPort(id);
    }

    @PostMapping(value = "/doThreadPoolTask")
    public String doThreadPoolTask(){
        orderService.doThreadPoolTask("order");
        return "success";
    }

}
